<template>
  <div>
    <el-card>
      <el-form :inline="true" :model="searchForm">
        <el-form-item v-if="userInfo.type==='1' || userInfo.type==='2'" label="学号">
          <el-input
            v-model="searchForm.accountNumber"
            placeholder="请输入"
            clearable
          ></el-input>
        </el-form-item>
        <el-form-item label="试卷标题">
          <el-input
            v-model="searchForm.paperTitle"
            placeholder="请输入"
            clearable
          ></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="getData()">查询</el-button>
          <!-- <el-button type="primary">
          <a style="color:white" :href="'http://zhangxh.free.idcfengye.com/VehicleManagement/user/exportUserInfoList?accountNumber=' + searchForm.accountNumber">导出</a>
          </el-button> -->
        </el-form-item>
      </el-form>
      <!-- 数据列表-->
      <el-table
        :data="tableData.slice((currentPage-1)*PageSize,currentPage*PageSize)"
        border
        class="table"
        ref="multipleTable"
        highlight-current-row
      >
        <el-table-column
          prop="student.accountNumber"
          label="学号"
          min-width="140"
        ></el-table-column>
        <el-table-column
          prop="student.name"
          label="姓名"
          min-width="140"
        ></el-table-column>
        <!-- <el-table-column
          prop="clazz"
          label="班级"
          min-width="140"
        >
          <template slot-scope="scope">
            {{ scope.row.clazz.grade }}年级-{{ scope.row.clazz.classNumber }}班
          </template>
        </el-table-column> -->
        <el-table-column
          prop="paper.subject"
          label="科目"
          min-width="140"
        ></el-table-column>
        <el-table-column
          prop="paper.title"
          label="试卷标题"
          min-width="140"
        ></el-table-column>
        <el-table-column
          prop="score"
          label="分数"
          min-width="140"
        ></el-table-column>
        <el-table-column
          prop="examStartDate"
          label="答题开始时间"
          min-width="140"
        ></el-table-column>
        <el-table-column
          prop="examEndDate"
          label="答题结束时间"
          min-width="140"
        ></el-table-column>
        <!-- <el-table-column label="住址" min-width="150"> -->
          <!-- 使用作用域插槽，可以获取这一行返回的数据 -->
          <!-- <template slot-scope="scope">
            {{ scope.row.buildingNumber }}号楼-{{ scope.row.unitNumber }}单元-{{
              scope.row.houseNumber
            }}
          </template>
        </el-table-column> -->

      </el-table>
      <!-- 分页 -->
      <div class="pagination">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="currentPage"
          :page-sizes="pageSizes"
          :page-size="PageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="tableData.length"
        >
        </el-pagination>
      </div>
    </el-card>
  </div>
</template>
<script>
import webservice from '../../../api/webservice'
export default {
  data() {
    return {
      tableData: [],
      // 默认显示第几页
        currentPage: 1,
        // 个数选择器（可修改）
        pageSizes: [10, 20,30,40,50],
        // 默认每页显示的条数（可修改）
        PageSize: 10,
      searchForm: {}, //查询对象
      dialogTitle: "",
      scoreInfoRules:{
          
      },
      userInfo:{}
    };
  },
  created(){
      this.userInfo = JSON.parse(sessionStorage.getItem('userInfo'))
      if(this.userInfo.type==='0'){
        this.searchForm.accountNumber = this.userInfo.accountNumber
      }else{
        this.searchForm.accountNumber = ''
      }
      this.getData();
  },
  mounted() {
    
  },
  methods: {
    // 分页
    // 每页显示的条数
    handleSizeChange(val) {
        // 改变每页显示的条数 
        this.PageSize = val
        console.log(this.pageSizes)
        // 注意：在改变每页显示的条数时，要将页码显示到第一页
        this.currentPage = 1
    },
    // 显示第几页
    handleCurrentChange(val) {
        // 改变默认的页数
        this.currentPage = val
    },
    getData() {
      if(this.userInfo.type==='0'){
        var _param = {
        accountNumber: this.userInfo.accountNumber,
        paperTitle:this.searchForm.paperTitle,
        
      };
      }else{
        var _param = {
        accountNumber: this.searchForm.accountNumber,
        paperTitle:this.searchForm.paperTitle,
      };
      }
       let _params = JSON.stringify(_param)
      webservice.HttpPost("/api/score/selectScoreList", _params, (data) => {
        if (data.code === 200) {
          this.tableData = data.data;
        } else {
          this.$message.error({
            message: data.message,
            showClose: true,
            duration: 1000,
          });
        }
      });
    },
  },
};
</script>